//
//  Moment.swift
//  WeChatClient
//
//  Created by AI Assistant on 2025/10/31.
//

import Foundation

enum MomentContentType {
    case text
    case singleImage
    case multipleImages
    case video
}

struct MomentComment: Identifiable, Codable {
    let id = UUID()
    let user: User
    let content: String
    let timestamp: Date
}

struct Moment: Identifiable, Codable {
    let id = UUID()
    let user: User
    let content: String
    let contentType: MomentContentType
    let images: [String] // 图片名称或URL
    let videoUrl: String?
    let timestamp: Date
    var likes: [User]
    var comments: [MomentComment]
    
    init(user: User, content: String, contentType: MomentContentType = .text, images: [String] = [], videoUrl: String? = nil, timestamp: Date = Date()) {
        self.user = user
        self.content = content
        self.contentType = contentType
        self.images = images
        self.videoUrl = videoUrl
        self.timestamp = timestamp
        self.likes = []
        self.comments = []
    }
    
    var isLikedByCurrentUser: Bool {
        return likes.contains { $0.userName == User.currentUser.userName }
    }
}

extension MomentContentType: Codable {}
